package com.situ.allaia.api.config;

import com.situ.allaia.api.common.Global;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ApiConfig implements WebMvcConfigurer {
    @Bean
    Jackson2ObjectMapperBuilderCustomizer customizer(){
        return builder -> builder.failOnEmptyBeans(false);
    }
    //重置
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/upload/**")
                .addResourceLocations("file:" + Global.UPLOAD_DIRECTORY);
    }
}
